package org.loujiarong.yugioh.gameplay.duel;

import org.loujiarong.yugioh.gameplay.card.Card;
import org.loujiarong.yugioh.gameplay.card.DummyCard;
import org.loujiarong.yugioh.gameplay.card.Monster;
import org.loujiarong.yugioh.gameplay.card.Spell;
import org.loujiarong.yugioh.gameplay.card.Trap;

public class PlayingField
{
   Card[] monsterZone;
   Card[] spellTrapZone;

   public PlayingField() {
      monsterZone = new Card[5];
      spellTrapZone = new Card[5];
      DummyCard dummyCard = DummyCard.getDummyCard();
      for(int i=0;i<5;++i)
    	  monsterZone[i] = dummyCard;
      for(int i=0;i<5;++i)
    	  spellTrapZone[i] = dummyCard;	  
   }

   public void remove(Card card) {
      if (card instanceof Spell || card instanceof Trap) {
         for (int i = 0; i < spellTrapZone.length; ++ i) {
            if (spellTrapZone[i].equals(card)) {
               spellTrapZone[i] = DummyCard.getDummyCard();
               return;
            }
         }
      }
      else {
         for (int i = 0; i < monsterZone.length; ++ i) {
            if (monsterZone[i].equals(card)) {
               monsterZone[i] = DummyCard.getDummyCard();
               return;
            }
         }
      }
   }
   
	public Card[] getMonsterZone() {
		return monsterZone;
	}
	
	public void setMonsterZone(Card[] monsterZone) {
		this.monsterZone = monsterZone;
	}
	
	public Card[] getSpellTrapZone() {
		return spellTrapZone;
	}
	
	public void setSpellTrapZone(Card[] spellTrapZone) {
		this.spellTrapZone = spellTrapZone;
	}
}
